/*
 *   Copyright 2021 zzh
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */

package com.aduib.boot.common.disruptor;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: AbstractEventHandlerBuildStrategy
 * @author: zzh
 * @date: 2021/9/16 15:49
 */
public abstract class AbstractEventHandlerBuildStrategy implements EventHandlerBuildStrategy {

  private final List<ElementEventHandler<?>> withOneHandlers = new ArrayList<>();

  private final List<ElementEventHandler<?>> withTwoHandlers = new ArrayList<>();

  private final List<ElementEventHandler<?>> thenOneHandlers = new ArrayList<>();

  private final List<ElementEventHandler<?>> thenTwoHandlers = new ArrayList<>();

  @Override
  public void addWithOneHandler(ElementEventHandler<?> adaptor) {
    withOneHandlers.add(adaptor);
  }

  @Override
  public void addWithTwoHandler(ElementEventHandler<?> adaptor) {
    withTwoHandlers.add(adaptor);
  }

  @Override
  public void addThenOneHandler(ElementEventHandler<?> adaptor) {
    thenOneHandlers.add(adaptor);
  }

  @Override
  public void addThenTwoHandler(ElementEventHandler<?> adaptor) {
    thenTwoHandlers.add(adaptor);
  }

  @Override
  public void addWithOneHandler(List<ElementEventHandler<?>> adaptors) {
    withOneHandlers.addAll(adaptors);
  }

  @Override
  public void addWithTwoHandler(List<ElementEventHandler<?>> adaptors) {
    withTwoHandlers.addAll(adaptors);
  }

  @Override
  public void addThenOneHandler(List<ElementEventHandler<?>> adaptors) {
    thenOneHandlers.addAll(adaptors);
  }

  @Override
  public void addThenTwoHandler(List<ElementEventHandler<?>> adaptors) {
    thenTwoHandlers.addAll(adaptors);
  }

  public List<ElementEventHandler<?>> getWithOneHandlers() {
    return withOneHandlers;
  }

  public List<ElementEventHandler<?>> getWithTwoHandlers() {
    return withTwoHandlers;
  }

  public List<ElementEventHandler<?>> getThenOneHandlers() {
    return thenOneHandlers;
  }

  public List<ElementEventHandler<?>> getThenTwoHandlers() {
    return thenTwoHandlers;
  }
}
